﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace JQGJJ
{
    class Algorithm
    {
        public static List<double> ksj_ks(double col, DataTable table)
        {
            List<double> result = new List<double>();
            if (table.Columns.Count>0)
            {
                string fieldName = table.Columns[0].ColumnName;
                List<string> subList = table.AsEnumerable().ToList().Select(x => x.Field<string>(fieldName)).ToList();
                double hs_double = subList.Count / 2;
                int hs = (int)Math.Floor(hs_double);
                double add = 0.0;
                for (int i =0; i < subList.Count; i++)
                {
                    add += Convert.ToDouble(subList[i]);
                }
                double m = add / (subList.Count - 1);

                for (int i =0; i< hs; i++)
                {
                    Random ran = new Random();
                    float rad = ran.Next(50,1000);
                    double res = m + rad;
                    result.Add(res);
                }
                return result;
            }
            return null;
        }

        public static List<double> ksj_hpc(double col, DataTable table)
        {
            List<double> result = new List<double>();
            if (table.Columns.Count > 0)
            {
                string fieldName = table.Columns[0].ColumnName;
                List<string> subList = table.AsEnumerable().ToList().Select(x => x.Field<string>(fieldName)).ToList();
                double hs_double = subList.Count / 2;
                int hs = (int)Math.Floor(hs_double);
                double add = 0.0;
                for (int i = 0; i < subList.Count; i++)
                {
                    add += Convert.ToDouble(subList[i]);
                }
                double m = add / (subList.Count - 1);

                for (int i = 0; i < hs; i++)
                {
                    Random ran = new Random();
                    float rad = ran.Next(50, 1000);
                    double res = hs + 0.2 * m + rad;
                    result.Add(res);
                }
                return result;
            }
            return null;
        }

        public static List<double> ksj_hzy(double col, DataTable table)
        {
            List<double> result = new List<double>();
            if (table.Columns.Count > 0)
            {
                string fieldName = table.Columns[0].ColumnName;
                List<string> subList = table.AsEnumerable().ToList().Select(x => x.Field<string>(fieldName)).ToList();
                double hs_double = subList.Count / 2;
                int hs = (int)Math.Floor(hs_double);
                double add = 0.0;
                for (int i = 0; i < subList.Count; i++)
                {
                    add += Convert.ToDouble(subList[i]);
                }
                double m = add / (subList.Count - 1);

                for (int i = 0; i < hs; i++)
                {
                    Random ran = new Random();
                    float rad = ran.Next(50, 1000);
                    double res = 1.1 * m + rad;
                    result.Add(res);
                }
                return result;
            }
            return null;
        }

        public static List<double> ksj_zsgd(double col, DataTable table)
        {
            List<double> result = new List<double>();
            if (table.Columns.Count > 0)
            {
                string fieldName = table.Columns[0].ColumnName;
                List<string> subList = table.AsEnumerable().ToList().Select(x => x.Field<string>(fieldName)).ToList();
                double hs_double = subList.Count / 2;
                int hs = (int)Math.Floor(hs_double);
                double add = 0.0;
                for (int i = 0; i < subList.Count; i++)
                {
                    add += Convert.ToDouble(subList[i]);
                }
                double m = add / (subList.Count - 1);
                double zsfd = m / 5;
                for (int i = 0; i < hs; i++)
                {
                    Random ran = new Random();
                    float rad = ran.Next(50, 1000);
                    double zs = zsfd * rad;
                    double res = zs + Convert.ToDouble(subList[i]);
                    result.Add(res);
                }
                return result;
            }
            return null;
        }

        public static List<string>other(int index)
        {
            List<string> result = new List<string>();
            switch (index)
            {
                case 1:
                    for (int i =0; i< 20000; i++)
                    {
                        result.Add("F1");
                    }
                    break;
                case 2:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F2");
                    }
                    break;
                case 3:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F3");
                    }
                    break;
                case 4:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F4");
                    }
                    break;
                case 5:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F5");
                    }
                    break;
                case 6:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F6");
                    }
                    break;
                case 7:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F7");
                    }
                    break;
                case 8:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F8");
                    }
                    break;
                case 9:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F9");
                    }
                    break;
                case 10:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F10");
                    }
                    break;
                case 11:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F11");
                    }
                    break;
                case 12:
                    for (int i = 0; i < 20000; i++)
                    {
                        result.Add("F12");
                    }
                    break;

                default:
                    break;
            }
            return result;

        }
    }
}
